<?php

namespace JsonLowCode\Form\Fields;

use JsonLowCode\Schema;
use JsonLowCode\UI\NSwitch;
use JsonLowCode\Form\Abstract\FieldAbstract;
use JsonLowCode\Form\Traits\HasDisabled;
use JsonLowCode\Form\Traits\HasSize;

/**
 * @property NSwitch $element
 */
class SwitchField extends FieldAbstract
{
    use HasDisabled, HasSize;

    protected function booting(): void
    {
        $this->element = new NSwitch();
        $this->options();
    }

    /**
     * @param string|Schema $checkLabel
     * @param string|Schema $uncheckLabel
     * @param int|string $checkValue
     * @param int|string $uncheckValue
     * @return $this
     */
    public function options(string|Schema $checkLabel = '是', string|Schema $uncheckLabel = '否', int|string $checkValue = 1, int|string $uncheckValue = 0): static
    {
        $this->element->slotChecked($checkLabel);
        $this->element->slotUnChecked($uncheckLabel);
        $this->element->checkedValue($checkValue);
        $this->element->uncheckedValue($uncheckValue);
        return $this;
    }
}
